package com.boot.dto;

import lombok.Data;
import org.camunda.bpm.engine.history.HistoricProcessInstance;

import java.util.Date;

@Data
public class HistoricProcessInstanceDto {
    private String id;
    private String businessKey;
    private String processDefinitionId;
    private String processDefinitionKey;
    private Date startTime;
    private Date endTime;
    private Long durationInMillis;
    private String endActivityId;
    private String state;

    public static HistoricProcessInstanceDto from(HistoricProcessInstance instance) {
        HistoricProcessInstanceDto dto = new HistoricProcessInstanceDto();
        dto.setId(instance.getId());
        dto.setBusinessKey(instance.getBusinessKey());
        dto.setProcessDefinitionId(instance.getProcessDefinitionId());
        dto.setProcessDefinitionKey(instance.getProcessDefinitionKey());
        dto.setStartTime(instance.getStartTime());
        dto.setEndTime(instance.getEndTime());
        dto.setDurationInMillis(instance.getDurationInMillis());
        dto.setEndActivityId(instance.getEndActivityId());
        dto.setState(instance.getState());
        return dto;
    }
}
